package com.cxx.home.dto.product;

import com.cxx.common.PlainView;
import com.cxx.common.ReadView;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.PositiveOrZero;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@Getter
@Setter
@JsonView(PlainView.class)
public class ProductDto {
    @Schema(description = "id")
    @JsonView(ReadView.class)
    private Long id;

    @Schema(description = "名称")
    @NotBlank(message = "商品名称不能为空")
    private String name;

    @Schema(description = "购买日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date purchaseDate;

    @Schema(description = "过期日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date expiryDate;

    @Schema(description = "总天数")
    @JsonView(ReadView.class)
    private Integer totalDay;

    @Schema(description = "价格")
    @PositiveOrZero(message = "商品价格必须大于等于0")
    private Double price;

    @Schema(description = "日均价格")
    @JsonView(ReadView.class)
    private Double averagePrice;

    @Schema(description = "类别")
    private String category;

    @Schema(description = "购买人")
    private String purchaser;

    @Schema(description = "购买渠道")
    private String channel;

    @Schema(description = "图片路径")
    private String imageUrl;
}
